﻿@page "/account/{tab}/index"
@page "/account/{tab}"

@inherits SsoCompontentBase
@inject IClientStore _clientStore
@inject IAuthenticationSchemeProvider _schemeProvider
@inject IAuthClient _authClient
@inject EnvironmentDataService _environmentData
@layout SimpleLayout
@implements IDisposable

@if (_viewModel.EnableLocalLogin)
{
    <MCard Width=510 Height=640 MaxHeight="640">
        <div class="tab-header login-tab">
            <MTabs Value="@ComputedTab" ValueChanged="TabChanged" BackgroundColor="transparent" Color="primary" HideSlider Grow>
                <MTab Value="@("login")" Class="neutral-lighten-4--text" Style="height:60px;">
                    <MBorder Border="Borders.Top" Size="4" Class="full-height d-flex flex-column" Value="@(ComputedTab == "login")">
                        <span class="flex-grow-1 d-flex align-center mt-n1 text-h6 neutral-lighten-4--text neutral-text">
                            @T("Login")
                        </span>
                    </MBorder>
                </MTab>
                <MTab Value="@("register")" Style="height:60px;">
                    <MBorder Border="Borders.Top" Size="4" Class="full-height d-flex flex-column" Value="@(ComputedTab == "register")">
                        <span class="flex-grow-1 d-flex align-center mt-n1 text-h6 neutral-lighten-4--text neutral-text">
                            @T("Register")
                        </span>
                    </MBorder>

                </MTab>
            </MTabs>
        </div>
        <MTabsItems Value="@ComputedTab">
            <MTabItem Value="@("login")">
                <CascadingValue Value="@ReturnUrl">
                    <LoginSection LoginHint="@_loginHint" ExternalProviderList="@_viewModel.VisibleExternalProviders"/>
                </CascadingValue>
            </MTabItem>
            <MTabItem Value="@("register")">
                <CascadingValue Value="@ReturnUrl">
                    <RegisterSection RegisterFields="@_viewModel.RegisterFields.ToList()"/>
                </CascadingValue>
            </MTabItem>
        </MTabsItems>
    </MCard>
}
else
{
    @if (_viewModel.VisibleExternalProviders.Any())
    {
        <ExternalProviders ExternalProviderList="@_viewModel.VisibleExternalProviders" ReturnUrl="@ReturnUrl"/>
    }
    else
    {
        <MAlert Type="AlertTypes.Warning">
            <strong>Invalid login request</strong>
            There are no login schemes configured for this request.
        </MAlert>
    }
}